<?php

/**
 * This is the model class for table "seo".
 *
 * The followings are the available columns in table 'seo':
 * @property string $id
 * @property string $sef
 * @property string $title_id
 * @property string $description_id
 * @property string $keywords_id
 *
 * The followings are the available model relations:
 * @property Text $title
 * @property Text $description
 * @property Text $keywords
 * @property Static[] $statics
 * @property StaticCategory[] $staticCategories
 */
class Seo extends AActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @return Seo the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'seo';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('sef, title_id, description_id, keywords_id', 'required'),
			array('sef', 'length', 'max'=>250),
			array('title_id, description_id, keywords_id', 'length', 'max'=>10),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('id, sef, title_id, description_id, keywords_id', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'title' => array(self::BELONGS_TO, 'Text', 'title_id'),
			'description' => array(self::BELONGS_TO, 'Text', 'description_id'),
			'keywords' => array(self::BELONGS_TO, 'Text', 'keywords_id'),
			'statics' => array(self::HAS_MANY, 'Static', 'seo_id'),
			'staticCategories' => array(self::HAS_MANY, 'StaticCategory', 'seo_id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'sef' => 'Sef',
			'title_id' => 'Title',
			'description_id' => 'Description',
			'keywords_id' => 'Keywords',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id,true);
		$criteria->compare('sef',$this->sef,true);
		$criteria->compare('title_id',$this->title_id,true);
		$criteria->compare('description_id',$this->description_id,true);
		$criteria->compare('keywords_id',$this->keywords_id,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	public function getDeleteConfig(){
		return array(
			'title',
			'keywords',
			'description',
		);
	}
}